package com.pengxun.mall.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.szeastroc.common.result.Result;
import com.szeastroc.common.result.ResultUtils;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;



import  com.pengxun.mall.dto.StoreGroupDTO;
import  com.pengxun.mall.dto.StoreGroupSearchDTO;
import  com.pengxun.mall.vo.StoreGroupVO;
import  com.pengxun.mall.service.StoreGroupService;
import com.szeastroc.common.jdbc.page.Page;

@RestController
@RequestMapping("/storeGroup")
public class  StoreGroupController{

   @Resource
   private StoreGroupService storeGroupService;
   
   @RequestMapping("/insert")
   public Result<Object> insert(@RequestBody StoreGroupDTO storeGroupDTO){
       storeGroupService.insert(storeGroupDTO);    
	   return ResultUtils.render();
   }
   
   @RequestMapping("/update")
   public Result<Object> update(@RequestBody StoreGroupDTO storeGroupDTO){
      storeGroupService.update(storeGroupDTO);
	   return ResultUtils.render();
   }
   
   @RequestMapping("/delete")
   public Result<Object> delete(Integer id){
       storeGroupService.delete(id);
	   return ResultUtils.render();
   }
   
   @RequestMapping("/findById")
   public Result<Object> findById(Integer id) {
		return ResultUtils.render(storeGroupService.findById(id));
	}
	
   @RequestMapping("/findAll")
   public Result<Object> findAll() {
		List<StoreGroupVO> storeGroupVOs = storeGroupService.findAll();
		return ResultUtils.render(storeGroupVOs);
	}
	
   @RequestMapping("/findByPage")
   public Result<Object> findByPage(@RequestBody StoreGroupSearchDTO storeGroupSearchDTO) {
	    Page page =  storeGroupService.findByPage(storeGroupSearchDTO);
		return ResultUtils.render(page);
	}
}
